-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Versat, crypto software implementations and versat implementations as well. Added tests and they all pass #82
Conversation
…g is working properly
…since they take too long and they run on fpga fine
Is this failing because the MEM_NO_READ_ON_WRITE macro is not being read? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
I added some comments with recomendations/sugestions
-
cyclonev synthesis fails fit step
software/sw_build.mk
Outdated
|
||
#Lines below were auto generated by iob_soc_utils.py | ||
UTARGETS+=iob_eth_rmac.h | ||
EMUL_HDR+=iob_eth_rmac.h | ||
iob_eth_rmac.h: | ||
echo "#define ETH_RMAC_ADDR 0x$(RMAC_ADDR)" > $@ | ||
|
||
CONSOLE_CMD ?=rm -f soc2cnsl cnsl2soc; $(IOB_CONSOLE_PYTHON_ENV) $(PYTHON_DIR)/console_ethernet.py -L -c $(PYTHON_DIR)/console.py -m "$(RMAC_ADDR)" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as stated in the comment:
these lines are added automatically by iob_soc_utils.py
script during setup if
iob_soc_opencryptolinux.conf
has USE_ETHERNET
so we can discard this addition
#Lines below were auto generated by iob_soc_utils.py | |
UTARGETS+=iob_eth_rmac.h | |
EMUL_HDR+=iob_eth_rmac.h | |
iob_eth_rmac.h: | |
echo "#define ETH_RMAC_ADDR 0x$(RMAC_ADDR)" > $@ | |
CONSOLE_CMD ?=rm -f soc2cnsl cnsl2soc; $(IOB_CONSOLE_PYTHON_ENV) $(PYTHON_DIR)/console_ethernet.py -L -c $(PYTHON_DIR)/console.py -m "$(RMAC_ADDR)" |
iob_soc_opencryptolinux.py
Outdated
VERSAT_SPEC = "versatSpec.txt" | ||
VERSAT_EXTRA_UNITS = os.path.realpath( | ||
os.path.join(os.path.dirname(__file__), "hardware/src/units") | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why set global variables that are only used once?
VERSAT_SPEC = "versatSpec.txt" | |
VERSAT_EXTRA_UNITS = os.path.realpath( | |
os.path.join(os.path.dirname(__file__), "hardware/src/units") | |
) |
@@ -86,6 +98,11 @@ def _create_instances(cls): | |||
@classmethod | |||
def _create_submodules_list(cls, extra_submodules=[]): | |||
"""Create submodules list with dependencies of this module""" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set variables here:
VERSAT_SPEC = "versatSpec.txt" | |
VERSAT_EXTRA_UNITS = os.path.realpath( | |
os.path.join(os.path.dirname(__file__), "hardware/src/units") | |
) |
iob_soc_opencryptolinux.py
Outdated
# OpenCrypts testcases | ||
shutil.copytree( | ||
f"{cls.setup_dir}/tests", f"{cls.build_dir}/tests", dirs_exist_ok=True | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we just place tests under ./software/src/tests
and they are automatically copied to BUILD_DIR
?
or add to ./software/versat/tests
and add versatSpec.txt
to ./software/versat/versatSpec.txt
for versat-specific files
software/sw_build.mk
Outdated
# NOTE(Ruben): To speed up simulation, the following files can be commented out to greatly reduce filesize from around ~120Kb to ~20Kb. | ||
IOB_SOC_OPENCRYPTOLINUX_FW_SRC+=src/versat_crypto.c | ||
IOB_SOC_OPENCRYPTOLINUX_FW_SRC+=src/versat_crypto_tests.c | ||
IOB_SOC_OPENCRYPTOLINUX_FW_SRC+=src/crypto/aes.c | ||
IOB_SOC_OPENCRYPTOLINUX_FW_SRC+=$(wildcard src/crypto/McEliece/*.c) | ||
IOB_SOC_OPENCRYPTOLINUX_FW_SRC+=$(wildcard src/crypto/McEliece/common/*.c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sugestion: add only to sw_build.mk
if we are using versat? Use a setup like USE_ETHERNET
?
or skip sources for simulation flows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did everything except this part. How do I approach this in the correct python setup approach? I do not see any variable inside the Makefile that indicates we are simulating vs running fpga. Also do not see any direct way of telling on the python side, so cannot conditionally insert the lines in sw_build because cannot know if doing setup to sim or doing setup to run fpga.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An ideal solution would be to remove unused code from compilation.
After some search, it seems that adding the compilation and linking flags: -fdata-sections -ffunction-sections -Wl,--gc-sections
would remove unused functions.
But it yields an elf without sections:
riscv64-unknown-elf-objcopy: error: the input file 'iob_soc_opencryptolinux_boot.elf' has no sections
I think we should just keep this as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sugestion: add only to
sw_build.mk
if we are using versat? Use a setup likeUSE_ETHERNET
? or skip sources for simulation flows
I've added a way to skip sources for simulation in a suggestion below, but I have not tried to run it, so it may break compilation if the firmware requires those functions to be present.
submodules/VERSAT
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: new commit not present in upstream repository.
PR iob-versat changes to iobundle/iob-versat
Checks are failing because the timeout for cyclonev was too low, with Versat compilation takes more time and CycloneV was timing out in the middle of running Linux. Baremetal check was working in previous commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes seem good. I have not reviewed crypto-related software code.
However, I've added a suggestion for a better implementation of the default.nix
file.
I also included some suggestions about preventing inclusion of sources in the sw_build.mk
file during simulation.
@@ -63,14 +64,23 @@ TEMPLATE_LDS=src/[email protected] | |||
|
|||
IOB_SOC_OPENCRYPTOLINUX_CFLAGS ?=-Os -nostdlib -march=rv32imac -mabi=ilp32 --specs=nano.specs -Wcast-align=strict | |||
|
|||
IOB_SOC_OPENCRYPTOLINUX_INCLUDES=-I. -Isrc | |||
IOB_SOC_OPENCRYPTOLINUX_INCLUDES=-I. -Isrc -Isrc/crypto/McEliece -Isrc/crypto/McEliece/common |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can include some sources only if running on the FPGA:
IOB_SOC_OPENCRYPTOLINUX_INCLUDES=-I. -Isrc -Isrc/crypto/McEliece -Isrc/crypto/McEliece/common | |
IOB_SOC_OPENCRYPTOLINUX_INCLUDES=-I. -Isrc | |
ifneq ($(SIMULATION),1) | |
IOB_SOC_OPENCRYPTOLINUX_INCLUDES+=-Isrc/crypto/McEliece -Isrc/crypto/McEliece/common | |
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not do this because the includes in gcc is for header lookups and stuff. None of which actually adds code so it's not a problem if they get added regardless.
There is some warnings when simulating from versat on icarus but nothing serious.
Tests for SHA, AES and McEliece all pass. They only run during fpga-run since they take too long to sim.
default.nix had to change from a simple link to a real file in order to add the "(callPackage ./submodules/VERSAT/versat.nix { })" line.